﻿
#include <iostream>
#include "Base.h"

int main()
{
    // 向 factory 注册类
    DO_REGISTER_CLASS(Child1);
    DO_REGISTER_CLASS(Child2);
    DO_REGISTER_CLASS(Child2);

    // 根据类名创建 Child1
    Base* mBase = Factory::getInstance()->create("Child1");
    mBase->work();
    // 根据类名创建 Child2
    mBase = Factory::getInstance()->create("Child2");
    mBase->work();
    // 根据类名，尝试创建 Child3，但并不存在 Child3
    Factory::getInstance()->create("Child3");
}
